package com.gxa.service.statistics.impl;

import com.gxa.common.R.ResponseData;
import com.gxa.mapper.statistics.StatisticMapper;
import com.gxa.pojo.Dept;
import com.gxa.pojo.Month2022;
import com.gxa.service.statistics.StatisticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
public class StatisticServiceImpl implements StatisticService {

    @Autowired
    private StatisticMapper statisticMapper;

    @Autowired
    private ResponseData r;

    @Override
    //返回成功查询综合数据统计数据
    public ResponseData contextualData() {

        String role = statisticMapper.selectAllRole();
        String user = statisticMapper.selectAllUser();
        String dept = statisticMapper.selectAllDept();
        String emp = statisticMapper.selectAllEmp();
        String jianLi = statisticMapper.selectAllJianLi();
//========================================

        r.setCode(200);
        r.setMsg("成功查询综合数据统计");
        ArrayList<Object> list = new ArrayList<>();
        HashMap<String, String> hashMap =null;

        hashMap= new HashMap<>();
        hashMap.put("name","全部角色组");
        hashMap.put("value",role);
        list.add(hashMap);
//        hashMap.put("全部角色","5组");
        hashMap= new HashMap<>();
        hashMap.put("name","全部管理员");
        hashMap.put("value",user);
        list.add(hashMap);
//        hashMap.put("全部管理员","6个");
        hashMap= new HashMap<>();
        hashMap.put("name","所有部门");
        hashMap.put("value",dept);
        list.add(hashMap);
//        hashMap.put("所有部门","8个");
        hashMap= new HashMap<>();
        hashMap.put("name","所有员工");
        hashMap.put("value",emp);
        list.add(hashMap);
//        hashMap.put("所有员工","3000人");
        hashMap= new HashMap<>();
        hashMap.put("name","人才储备库");
        hashMap.put("value",jianLi);
        list.add(hashMap);
//        hashMap.put("人才储备库","200人");
        r.setData(list);

        return r;
    }

    @Override
    //返回成功查询部门员工统计数据
    public ResponseData deptData() {
        r.setCode(200);
        r.setMsg("成功查询部门员工统计");

        ArrayList<Object> list = new ArrayList<>();
        HashMap<String, String> hashMap =null;

        List<Dept> listDept = statisticMapper.selectDeptInfo();

        for (Dept d:listDept){
            hashMap= new HashMap<>();
            hashMap.put("name",d.getName());
            long id = d.getId();
            String s = Long.toString(id);
            //部门人数
            String deptPeople = statisticMapper.selectEmpByDeptId(s);
            hashMap.put("value",deptPeople);
            list.add(hashMap);
        }

       /* hashMap= new HashMap<>();
        hashMap.put("name","人事部");
        hashMap.put("value","200");
        list.add(hashMap);
//        hashMap.put("人事部","200人");
        hashMap= new HashMap<>();
        hashMap.put("name","技术部");
        hashMap.put("value","300");
        list.add(hashMap);
//        hashMap.put("技术部","300人");
        hashMap= new HashMap<>();
        hashMap.put("name","后勤部");
        hashMap.put("value","200");
        list.add(hashMap);
//        hashMap.put("后勤部","200人");
        hashMap= new HashMap<>();
        hashMap.put("name","财务部");
        hashMap.put("value","300");
        list.add(hashMap);
//        hashMap.put("财务部","300人");
        hashMap= new HashMap<>();
        hashMap.put("name","管理部");
        hashMap.put("value","300");
        list.add(hashMap);
//        hashMap.put("管理部","300人");*/

        r.setData(list);
        return r;
    }

    @Override
    //返回成功查询人才储备统计数据
    public ResponseData reserveData(){
        r.setCode(200);
        r.setMsg("成功查询人才储备统计");

        ArrayList<Object> list = new ArrayList<>();
        HashMap<String, String> hashMap =null;
        //=====================
        //已经入职的人数
        String jianLiByStatus4 = statisticMapper.jianLiByStatus4();
        //已过面试的人数
        String jianLiByStatus2 = statisticMapper.jianLiByStatus2();
        //未过面试的人数
        String jianLiByStatus3 = statisticMapper.jianLiByStatus3();
        //可查看简历
        String jianLiByStatus1 = statisticMapper.jianLiByStatus1();


        //========================
        hashMap= new HashMap<>();
        hashMap.put("name","已经入职的人数");
        hashMap.put("value",jianLiByStatus4);
        list.add(hashMap);
//        hashMap.put("已经入职的人数","200");
        hashMap= new HashMap<>();
        hashMap.put("name","已过面试的人数");
        hashMap.put("value",jianLiByStatus2);
        list.add(hashMap);
//        hashMap.put("已过面试的人数","100");
        hashMap= new HashMap<>();
        hashMap.put("name","未过面试的人数");
        hashMap.put("value",jianLiByStatus3);
        list.add(hashMap);
//        hashMap.put("未过面试的人数","200");
        hashMap= new HashMap<>();
        hashMap.put("name","可查看简历");
        hashMap.put("value",jianLiByStatus1);
        list.add(hashMap);
//        hashMap.put("未查看简历","300份");

        r.setData(list);
        return r;
    }

    @Override
    //返回成功查询员工在职状态统计数据
    public ResponseData staffActionData(){
        r.setCode(200);
        r.setMsg("成功查询员工在职状态统计");

        ArrayList<Object> list = new ArrayList<>();
        HashMap<String, String> hashMap =null;
        //=======================
        //在职员工人数
        String empByStatus1 = statisticMapper.empByStatus1();
        //离职员工人数
        String empByStatus2 = statisticMapper.empByStatus2();
        //===========================
        hashMap= new HashMap<>();
        hashMap.put("name","在职员工人数");
        hashMap.put("value",empByStatus1);
        list.add(hashMap);
//        hashMap.put("在职员工人数","1444人");
        hashMap= new HashMap<>();
        hashMap.put("name","离职员工人数");
        hashMap.put("value",empByStatus2);
        list.add(hashMap);
//        hashMap.put("离职员工人数","2人");

        r.setData(list);
        return r;
    }


    @Override
//返回成功查询员工黑白名单统计数据
    public ResponseData blackWhiteData(){
        r.setCode(200);
        r.setMsg("成功查询员工黑白名单统计");

        ArrayList<Object> list = new ArrayList<>();
        HashMap<String, String> hashMap =null;
        //===================
        //黑名单员工人数
        String black = statisticMapper.empByStatus3();
        //白名单员工人数
        String empByStatus1 = statisticMapper.empByStatus1();
        String empByStatus2 = statisticMapper.empByStatus2();
        int white=Integer.parseInt(empByStatus1)+Integer.parseInt(empByStatus2);
        String whiteString= String.valueOf(white);

        //===================
        hashMap= new HashMap<>();
        hashMap.put("name","黑名单员工人数");
        hashMap.put("value",black);
        list.add(hashMap);
//        hashMap.put("黑名单员工人数","6人");
        hashMap= new HashMap<>();
        hashMap.put("name","白名单员工人数");
        hashMap.put("value",whiteString);
        list.add(hashMap);
//        hashMap.put("白名单员工人数","1446人");

        r.setData(list);
        return r;
    }

   @Override
//返回成功查询员工基本统计数据
    public ResponseData staffData(){
        r.setCode(200);
        r.setMsg("成功查询员工基本统计");

        ArrayList<Object> list = new ArrayList<>();
        HashMap<String, String> hashMap =null;

        //=========================
       //黑名单员工人数
       String blackString = statisticMapper.empByStatus3();
       //在职员工人数
       String empByStatus1 = statisticMapper.empByStatus1();
       //离职员工人数
       String empByStatus2 = statisticMapper.empByStatus2();
       //白名单员工人数,即全部员工
       int white=Integer.parseInt(empByStatus1)+Integer.parseInt(empByStatus2);
       String whiteString= String.valueOf(white);
       //总数
       String all=String.valueOf(white+Integer.parseInt(blackString));
       //=========================

        hashMap= new HashMap<>();
        hashMap.put("name","黑名单员工");
        hashMap.put("value",blackString);
        list.add(hashMap);
//        hashMap.put("黑名单员工","6人");
        hashMap= new HashMap<>();
        hashMap.put("name","离职员工");
        hashMap.put("value",empByStatus2);
        list.add(hashMap);
//        hashMap.put("离职员工","2人");
        hashMap= new HashMap<>();
        hashMap.put("name","在职员工");
        hashMap.put("value",empByStatus1);
        list.add(hashMap);
//        hashMap.put("在职员工","1444人");
        hashMap= new HashMap<>();
        hashMap.put("name","全部员工");
        hashMap.put("value",whiteString);
        list.add(hashMap);
//        hashMap.put("全部员工","1446人");
        hashMap= new HashMap<>();
        hashMap.put("name","总数");
        hashMap.put("value",all);
        list.add(hashMap);
//        hashMap.put("总数","1452人");

        r.setData(list);
        return r;
    }



    @Override
//返回成功查询员工月份统计数据
    public ResponseData staffMonthData(){
        r.setCode(200);
        r.setMsg("成功查询员工2022年月份统计");

//        ArrayList<Object> arrayList = new ArrayList<>();

        ArrayList<String> listIn;

        HashMap<String,Object> hashMap;

        hashMap=new HashMap<>();

        listIn=new ArrayList<>();
        //====================
        Month2022 month2022Entry = statisticMapper.empMonthEntryDate();
        //===================
        listIn.add(month2022Entry.getJanuary());
        listIn.add(month2022Entry.getFebruary());
        listIn.add(month2022Entry.getMarch());
        listIn.add(month2022Entry.getApril());
        listIn.add(month2022Entry.getMay());
        listIn.add(month2022Entry.getJune());
        listIn.add(month2022Entry.getJuly());
        listIn.add(month2022Entry.getAugust());
        listIn.add(month2022Entry.getSeptember());
        listIn.add(month2022Entry.getOctober());
        listIn.add(month2022Entry.getNovember());
        listIn.add(month2022Entry.getDecember());
        hashMap.put("employees",listIn);  //入职

        listIn=new ArrayList<>();

        //====================
        Month2022 month2022Quit= statisticMapper.empMonthQuitDate();
        //===================
        listIn.add(month2022Quit.getJanuary());
        listIn.add(month2022Quit.getFebruary());
        listIn.add(month2022Quit.getMarch());
        listIn.add(month2022Quit.getApril());
        listIn.add(month2022Quit.getMay());
        listIn.add(month2022Quit.getJune());
        listIn.add(month2022Quit.getJuly());
        listIn.add(month2022Quit.getAugust());
        listIn.add(month2022Quit.getSeptember());
        listIn.add(month2022Quit.getOctober());
        listIn.add(month2022Quit.getNovember());
        listIn.add(month2022Quit.getDecember());
        hashMap.put("quit",listIn);  //离职

        listIn=new ArrayList<>();
        listIn.add("一");
        listIn.add("二");
        listIn.add("三");
        listIn.add("四");
        listIn.add("五");
        listIn.add("六");
        listIn.add("七");
        listIn.add("八");
        listIn.add("九");
        listIn.add("十");
        listIn.add("十一");
        listIn.add("十二");
        hashMap.put("mon",listIn);  //月份

        r.setData(hashMap);
        return r;
    }

    @Override
//返回成功查询员工性别统计数据
    public ResponseData staffSexData(){
        r.setCode(200);
        r.setMsg("成功查询员工性别统计");

        ArrayList<Object> list = new ArrayList<>();
        HashMap<String, String> hashMap =null;

        //=============
        String man = statisticMapper.empSex1();
        String woman = statisticMapper.empSex0();
        //=============

        hashMap= new HashMap<>();
        hashMap.put("name","男员工人数");
        hashMap.put("value",man);
        list.add(hashMap);
//        hashMap.put("男员工人数","900人");
        hashMap= new HashMap<>();
        hashMap.put("name","女员工人数");
        hashMap.put("value",woman);
        list.add(hashMap);
//        hashMap.put("女员工人数","100人");

        r.setData(list);
        return r;
    }
}
